Today I worked on emplementing median for numba. I expected it be a quick and easy work but it did not turned out the case. The way numba works is that you have to reimplement the numpy algorithms in numba so that can be lowered to its IR and then can be passed on to LLVM to jit it. Well at this point I'm not entirely sure why we need to do that, can't we make a tool that automatically applies numba jit to numpy, the current approach appears to pretty redundant because:
Anyway, so yesterday I submitted a work which was shitty, I, in a very sloppy manner, translated the CLRS code of median to python. thankfully the reviewer is quite friendly and he politely pointed out the mistakes. Another reviewer asked me what is the algorithm used by numpy, I digged the source and it turned out they used a hybrid of quickselect and the median of medians technique, this part of the code was written in C. I asked if we can use the same code but we Pitrou said that C implementation won't be avialable to the CUDA interface. I first though about translating the source to Python but then I translated the quickselect code mention in the references. The translation was kinda dirty and was very unpythonic. Plus that code failed to compile with the nopython option probably because not all branches of the code returned any value, though algorithmically that case wasn't possible. Then I went back and fixed my original code and it didn't work, for an hour or so I was fiddeling with stupid silly errors. Well, I guess an hour or two of competitive progamming a week won't hurt.